package popup

import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.PopupWindow
import android.widget.TextView
import app.AppContext
import com.hontech.pizzav2.R


class HintDialog(val title: String, val content: String, val parent: View) {

    private val mView = LayoutInflater.from(AppContext).inflate(R.layout.dialog_hint, null)
    private val mTextViewTitle = mView.findViewById<TextView>(R.id.id_hint_text_view_title)
    private val mTextViewContent = mView.findViewById<TextView>(R.id.id_hint_text_view_content)
    private val mButtonQuit = mView.findViewById<Button>(R.id.id_hint_button_quit)

    private val mWindow = PopupWindow(mView, 480, 600, true)

    init {
        mTextViewContent.text = content
        mTextViewTitle.text = title
        mButtonQuit.setOnClickListener {
            mWindow.dismiss()
        }
    }

    fun show() {
        mWindow.showAtLocation(parent, Gravity.CENTER, 0, 0)
    }
}
